//
// Created by 67678 on 2023/3/10.
//

#ifndef WEBSERVER_SOCKETSERVER_H
#define WEBSERVER_SOCKETSERVER_H

#include <vector>
#include <optional>
#include "../event/event.h"
#include "../util/nonCopyable.h"
#include "socketClient.h"

using namespace std;


namespace socket_epoll {
class SocketServer : util::NonCopyable {
public:
    static constexpr int PORT = 8000;

    //static constexpr int IP = 0x100007f; //127.0.0.1.
    static constexpr int IP = 0x802ca8c0; //127.0.0.1.
    static constexpr int MAX_CONNECTION_NUMS = 100000;

    static SocketServer &getInstance() {
        static SocketServer s;
        return s;
    }

    void init();

    std::optional<SocketClient> accept();

    vector<shared_ptr<event::Event>> getEvents();


private:
    SocketServer();

    ~SocketServer();

    int socket_ = -1;
};


}

#endif //WEBSERVER_SOCKETSERVER_H
